<?php

namespace App\Http\Middleware;

use Closure;

class AppMiddle
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        if ($request->app_token == env('APP_TOKEN')) {
            return $next($request);
        }
        $msg = 'lack of competence';
        $code = 10002;
        return response()->json(compact('msg', 'code'));
    }

}
